import 'package:core_package/core_package.dart';
import 'package:flutter/material.dart';

class LoginInputWidget extends StatelessWidget {
  final String? leftIcon;
  final Widget? leftIconWidget;
  final String? placeholder;
  final Widget? rightIcon;
  final Function(String value)? inputTextTapChange;
  final TextInputAction textInputAction;
  final int? maxLength;
  final TextInputType? keyboardType; //键盘样式
  final bool obscureText;

  const LoginInputWidget({
    Key? key,
    this.leftIcon,
    this.leftIconWidget,
    this.placeholder,
    this.rightIcon,
    this.inputTextTapChange,
    this.textInputAction = TextInputAction.done,
    this.maxLength,
    this.keyboardType,
    this.obscureText = false,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      decoration: BoxDecoration(
        borderRadius: BorderRadius.circular(3),
        border: Border.all(color: MyColors.formHex("#272727FF"), width: 0.5),
      ),
      child: ShowTitleInputListWidget(
        textFieldHeight: SizeFill.setRx(40),
        padding: EdgeInsets.zero,
        titleWidget: leftIconWidget ??
            Container(
              width: SizeFill.setRx(36),
              height: SizeFill.setRx(40),
              alignment: Alignment.center,
              child: Image.asset(
                MyAssetsImages.setAssetsImagesPath(leftIcon ?? ''),
                width: SizeFill.setRx(12),
                height: SizeFill.setRx(13),
              ),
            ),
        inputStyle: TextStyle(
          color: MyColors.formHex("#272727FF"),
          fontSize: MyFont.font12,
        ),
        placeholderStyle: TextStyle(
          color: MyColors.formHex("#CDCDCDFF"),
          fontSize: MyFont.font12,
        ),
        inputTextTapChange: (value) {
          if (inputTextTapChange != null) {
            inputTextTapChange?.call(value);
          }
        },
        icon: rightIcon,
        textAlign: TextAlign.left,
        showBottomLine: false,
        placeholder: placeholder ?? '',
        maxLength: maxLength,
        minLine: 1,
        keyboardType: keyboardType ?? TextInputType.text,
        obscureText: obscureText,
      ),
    );
  }
}
